package com.shishuo.cms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.shishuo.cms.dao.DownPageDao;
import com.shishuo.cms.entity.DownPageEntity;
import com.shishuo.cms.entity.vo.PageVo;

@Service
public class DownPageService extends BaseService<DownPageEntity, Long>
{
	private DownPageDao downPageDao;

	@Autowired
	public void setDownPageDao(DownPageDao downPageDao)
	{
		super.setBaseDao(downPageDao);
		this.downPageDao = downPageDao;
	}
	public PageVo<DownPageEntity> getAllListPage(int pageNum) throws Exception{
		PageVo<DownPageEntity> pageVo = new PageVo<DownPageEntity>(pageNum);
		List<DownPageEntity> list = downPageDao
				.getAllListPageByClassId(pageVo.getOffset(), pageVo.getRows(),0);
		pageVo.setList(list);
		pageVo.setCount(downPageDao.getAllListCountByClassId(0));
		return pageVo;
	}
	public PageVo<DownPageEntity> getAllListPageByClassId(int pageNum, long classId) throws Exception {
		PageVo<DownPageEntity> pageVo = new PageVo<DownPageEntity>(pageNum);
		List<DownPageEntity> list = downPageDao
				.getAllListPageByClassId(pageVo.getOffset(), pageVo.getRows(),classId);
		pageVo.setList(list);
		pageVo.setCount(downPageDao.getAllListCountByClassId(classId));
		return pageVo;
	}
}
